﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace SystemDiagramNew.TypeDefinition
{
	public class NodePositionComparer : IComparer<Node>
	{
		public int Compare(Node node1, Node node2)
		{
			XYZ position = node1.Position;
			XYZ position2 = node2.Position;
			if (Geometry.IsEqual(position.Z, position2.Z))
			{
				if (Geometry.IsEqual(position.Y, position2.Y))
				{
					if (Geometry.LessThan(position.X, position2.X))
					{
						return -1;
					}
				}
				else
				{
					if (Geometry.LessThan(position.Y, position2.Y))
					{
						return -1;
					}
					return 0;
				}
			}
			else if (Geometry.LessThan(position.Z, position2.Z))
			{
				return -1;
			}
			return 1;
		}
	}
}
